package com.aegean.MonitorExamSYS.conduction.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.monitor.business.MonitorBusiness;
import com.aegean.MonitorExamSYS.monitor.component.ExamineeState;
import com.aegean.MonitorExamSYS.monitor.component.MonitorValue;
import com.opensymphony.xwork2.ActionSupport;

@Controller("CheckMonitorsForConduction")
@Scope("prototype")
public class CheckMonitorsForConduction extends ActionSupport implements ServletRequestAware{
	@Resource
	MonitorBusiness business;
	private int total;
	private int position_Id;
	private List<MonitorValue> monitors;
	private boolean success;
	private HttpSession session;
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getPosition_Id() {
		return position_Id;
	}
	public void setPosition_Id(int position_Id) {
		this.position_Id = position_Id;
	}
	public List<MonitorValue> getMonitors() {
		return monitors;
	}
	public void setMonitors(List<MonitorValue> monitors) {
		this.monitors = monitors;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		try {
			position_Id=(Integer) session.getAttribute("positionQ_Id");
			monitors = business.showMonitorOnPosition(position_Id);
			total=monitors.size();
			success=true;
		} catch (Exception e) {
			// TODO: handle exception
			success=false;
			e.printStackTrace();
		}
		return SUCCESS;
	}
	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		session=arg0.getSession();
	}
}
